package com.neu.util;

import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

public class EmailUtil {
    public static boolean sendEmail(String toEmail){
        boolean flag=false;
        //带HTML解析的邮件
        Email email=new HtmlEmail();
        //发送服务器 smtp.126.com
        email.setHostName("smtp.126.com");
        email.setAuthentication("wty_520",Base64Util.decode("YW5xdWFuMTIz"));
        email.setCharset("UTF-8");
        try {
            email.setFrom("wty_520@126.com","HIGO");
            email.addTo(toEmail);
            email.setSubject("密码找回");
            String msg="<a href='http://localhost:8888/HAIGO/newPwd.jsp?u_mail="+toEmail+"'>点击修改密码</a>";
            System.out.println(msg);
            email.setMsg(msg);
            String rst=email.send();
            System.out.println(rst);
            flag=true;
        } catch (EmailException e) {
            e.printStackTrace();
        }
        return flag;
    }
}
